/*
 * Galaxium Messenger
 * Copyright (C) 2008 Paul Burton <paulburton89@gmail.com>
 * 
 * License: GNU General Public License (GPL)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


using System;

namespace Galaxium.Protocol.Facebook
{
	public static class FBPresence
	{
		private static IPresence _online;
		private static IPresence _offline;
		private static IPresence _idle;

		public static IPresence Online
		{
			get
			{
				if (_online == null)
					_online = new OnlinePresence ();
				
				return _online;
			}
		}

		public static IPresence Offline
		{
			get
			{
				if (_offline == null)
					_offline = new OfflinePresence ();
				
				return _offline;
			}
		}

		public static IPresence Idle
		{
			get
			{
				if (_idle == null)
					_idle = new IdlePresence ();
				
				return _idle;
			}
		}
		
		public static string GetIconString (IPresence presence)
		{
			if (presence.Equals (FBPresence.Online))
				return "galaxium-status-online";
			else if (presence.Equals (FBPresence.Idle))
				return "galaxium-status-idle";
			else
				return "galaxium-status-offline";
		}

		public static IPresence Get(BasePresence basePresence)
		{
			if (basePresence == BasePresence.Online)
				return Online;
			if (basePresence == BasePresence.Offline)
				return Offline;
			if (basePresence == BasePresence.Idle)
				return Idle;
			
			return null;
		}
	}

	internal sealed class OnlinePresence : AbstractPresence
	{
		public OnlinePresence ()
		{
			_basePresence = BasePresence.Online; 
		}
		
		public override string Icon
		{
			get { return "galaxium-tray-online"; }
		}
		
		public override string State
		{
			get { return "Online"; }
		}
	}

	internal sealed class OfflinePresence : AbstractPresence
	{
		public OfflinePresence ()
		{
			_basePresence = BasePresence.Offline; 
		}
		
		public override string Icon
		{
			get { return "galaxium-tray-offline"; }
		}
		
		public override string State
		{
			get { return "Offline"; }
		}
	}
	
	internal sealed class IdlePresence : AbstractPresence
	{
		public IdlePresence ()
		{
			_basePresence = BasePresence.Idle; 
		}
		
		public override string Icon
		{
			get { return "galaxium-tray-idle"; }
		}
		
		public override string State
		{
			get { return "Idle"; }
		}
	}
}
